/* Copyright (c) 2004-2024 Peigen.info. All rights reserved. */

package info.peigen.hotpot.business.account.core.repository.mapper;

import info.peigen.hotpot.business.account.core.repository.entity.AccountFreezeLogEntity;
import info.peigen.hotpot.business.account.facade.enums.AccountFreezeDirection;
import info.peigen.hotpot.business.account.facade.enums.AccountFreezeType;
import info.peigen.hotpot.component.data.repository.beetlsql.mapper.AbstractBeetlSqlMapper;
import org.beetl.sql.mapper.annotation.Select;
import org.beetl.sql.mapper.annotation.Sql;
import org.beetl.sql.mapper.annotation.Update;

import java.math.BigDecimal;
import java.util.List;

/**
 * <b>(AccountFreezeLogMapper)</b>
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2021/8/12
 */
@SuppressWarnings("AlibabaAbstractMethodOrInterfaceMethodMustUseJavadoc")
public interface AccountFreezeLogMapper extends AbstractBeetlSqlMapper<AccountFreezeLogEntity> {
    @Sql("select * from account_freeze_log where account_id = ?")
    @Select
    List<AccountFreezeLogEntity> findByAccountId(String accountId);

    @Sql("select * from account_freeze_log where account_id = ? and trade_id  = ? and freeze_type  = ? and direction  = ?")
    @Select
    List<AccountFreezeLogEntity> findByUni(String accountId, String tradeId, AccountFreezeType freezeType, AccountFreezeDirection direction);

    @Sql("select sum(freeze_amount) from account_freeze_log where account_id = ? and trade_id  = ? and freeze_type  = ? and direction ='Freeze'")
    @Select
    BigDecimal sumFreezeAmount(String accountId, String tradeId, AccountFreezeType freezeType);

    @Sql("select sum(freeze_amount) from account_freeze_log where account_id  = ? and freeze_type  = ? and direction ='Freeze'")
    @Select
    BigDecimal sumFreezeAmount(String accountId, AccountFreezeType freezeType);

    @Sql("delete from account_freeze_log where account_id = ?")
    @Update
    void deleteByAccountId(String accountId);

    @Sql("delete from account_freeze_log where trade_id = ?")
    @Update
    void deleteByTradeId(String tradeId);
}